# 产品类，最终要构建的对象
class Product:
    def __init__(self):
        self.parts = []

    def add(self, part):
        self.parts.append(part)

    def list_parts(self):
        return self.parts

# 抽象建造者类
class Builder:
    def build_part_a(self):
        pass

    def build_part_b(self):
        pass

    def build_part_c(self):
        pass

    def get_result(self):
        pass

# 具体建造者类
class ConcreteBuilder(Builder):
    def __init__(self):
        self.product = Product()

    def build_part_a(self):
        self.product.add("Part A")

    def build_part_b(self):
        self.product.add("Part B")

    def build_part_c(self):
        self.product.add("Part C")

    def get_result(self):
        return self.product

# 指挥者类，负责安排建造者对象的构建过程
class Director:
    def __init__(self, builder: Builder):
        self.builder = builder

    def construct(self):
        self.builder.build_part_a()
        self.builder.build_part_b()
        self.builder.build_part_c()
        return self.builder.get_result()

# 客户端代码
if __name__ == "__main__":
    builder = ConcreteBuilder()
    director = Director(builder)

    product = director.construct()
    print(product.list_parts())  # 输出: ['Part A', 'Part B', 'Part C']


'''
代码实现：
['Part A', 'Part B', 'Part C']
'''